const {
	Controller
} = require('uni-cloud-router')

module.exports = class CourseController extends Controller {
	// 多选课程       
	async selectionCourse(){
		const {username , course , credit} = this.ctx.data
		const user = await this.service.user.hasUser(username)
		if (!user) {
			return {
				code: 10001,
				message: '无此用户'
			}
		}
		return this.service.course.selectionCourse(course,credit)
	}
	
	// 选课
	async selectionSubmit(){
		const {username , course_id , class_id} = this.ctx.data
		return this.service.course.selectionSubmit(username , course_id , class_id)
	}
	
	// 退课
	async dropCourse(){
		const {username,class_id} = this.ctx.data
		return this.service.course.dropCourse(username,class_id)
	}
}